<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Log;
use Illuminate\Http\Request;
use App\Tools\Fun;

class LogGetRequests
{
    public function handle(Request $request, Closure $next)
    {
        if (!Fun::is_windows()) { 
            return $next($request);
        }
        
        // 记录所有请求参数
        Log::channel('get')->info("\nRequest Parameters:\n" . json_encode([
            'method' => $request->method(),
            'url' => $request->fullUrl(),
            'params' => $request->all(),
            'header' => [
                'role' => $request->header('role'),
                'openid' => $request->header('openid')
            ]
        ], JSON_PRETTY_PRINT));

        return $next($request);
    }
}